package com.zxx.pattern.mediatorPattern.mediator1;

/**
 * 中介者模式
 *
 * @author zxx on 2021/5/11
 */
public class TestMediator {

    public static void main(String[] args) {
        //初始化聊天室对象
        ChatRoom chatRoom = new ChatRoom();

        //添加用户
        User user1 = new User("User1");
        User user2 = new User("User2");
        User user3 = new User("User3");
        User user4 = new User("User4");
        User user5 = new User("User5");

        chatRoom.addUser(user1);
        chatRoom.addUser(user2);
        chatRoom.addUser(user3);
        chatRoom.addUser(user4);
        chatRoom.addUser(user5);

        //用户之间开始交流
        user1.sendMessage(chatRoom, "大家好 我是one");
        user4.sendMessage(chatRoom, "您好好 我是Four");
    }
}
